using JH;
using UnityEngine;
using UnityEngine.Serialization;

public class TestInjectA : MonoBehaviour
{
    [Inject("提供服务 1")] private TestInjectableService _service;
    [Inject("提供服务 2")] private ITestService _iTestService;
    [Inject] private A _a;
    [Inject] private B _b;

    [InjectInstance("提供服务 1"), SerializeField, Inject("提供服务 2")]
    private BoxCollider myCollider;

    [InjectAsset("TestInjectMat"), SerializeField]
    private Material testAssets;
    
    [InjectAsset("TestInjectMat")]
    public Material testAssets2;
    
    [InjectAsset][SerializeField]
    private CustomScriptableObject customScriptableObject;
    
    [Inject("提供服务 1", "提供服务 2")]
    private void InjectMethod(ITestService service, TestInjectableService aa)
    {
        Debug.Log("注入方法：" + aa.name);
        Debug.Log("注入方法：" + (service as MonoBehaviour)!.name);
    }

    void Start()
    {
        Debug.Log("注入字段：" + _service.name);
        Debug.Log("注入接口：" + (_iTestService as MonoBehaviour)!.name);
        Debug.Log("注入普通类：" + _b.TestName);
        Debug.Log("注入普通类：" + _a.GetHashCode());
        Debug.Log("注入Unity内置组件：" + myCollider);
       Debug.Log("注入Unity资产：" + testAssets);
        Debug.Log("注入Unity资产：" + testAssets2);
        Debug.Log("注入Unity资产：" + customScriptableObject);
    }

    // Update is called once per frame
    void Update()
    {
    }
}